-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-36760][sql-client] Supports to deploy script via sql client #25754
Conversation
Reviewed by Chi on 12/12/24 Group to test and/or review outside of the meeting. @tomncooper one you might want to look at. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fsk119 Thanks for your contribution, only some minor comments.
...able/flink-sql-jdbc-driver/src/test/java/org/apache/flink/table/jdbc/FlinkStatementTest.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliStrings.java
Outdated
Show resolved
Hide resolved
5d1f6dc
to
36cd7bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fsk119 Thanks for the update, LGTM.
...table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliOptionsParser.java
Outdated
Show resolved
Hide resolved
String scheme = StringUtils.lowerCase(uri.getScheme()); | ||
String clusterId; | ||
// local files | ||
if (scheme == null || scheme.equals("file")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better if we could support shipping local files to the remote? That said, I think the current implementation is also fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we just read the sql script file if the file is in local fs. It's not an easy work to ship files in the k8s deployment. It requires users to configure a remote oss env.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fsk119 Thanks for your contribution, LGTM overall, just left some minor comments.
@@ -35,16 +36,16 @@ public class CliOptions { | |||
|
|||
private final boolean isPrintHelp; | |||
private final String sessionId; | |||
private final URL initFile; | |||
private final URL sqlFile; | |||
private final URI initFile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just a little curious that why we change it to URI
type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because URL requires to qualify referred resources. For example, if users uses the hdfs://path/to/object as the input, the sql client needs to validate whether the protocol is valid. However, in the client side, users may not configure hdfs parameters.
@@ -213,6 +213,8 @@ public AttributedString build() { | |||
|
|||
public static final String MESSAGE_EXECUTE_STATEMENT = "Execute statement succeeded."; | |||
|
|||
public static final String MESSAGE_DEPLOY_SCRIPT = "Deploy script in application mode: "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Deploy SQL script in application mode: "?
BTW, the content after the colon is an SQL script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to align the style with other prompt message(we only upper case the first word), you can take a look at the line above.
The content after the colon is the cluster id, which helps users to find the deployment
@@ -331,6 +334,19 @@ public List<String> completeStatement(String statement, int position) { | |||
.getCandidates(); | |||
} | |||
|
|||
@Override | |||
public String deployScript(@Nullable String script, @Nullable URI uri) { | |||
return getResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would better that we check the two parameters can not be null simutaneously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I delay the check in the server side.
@@ -78,6 +80,12 @@ private YarnClusterDescriptor getClusterDescriptor(Configuration configuration) | |||
final YarnConfiguration yarnConfiguration = | |||
Utils.getYarnAndHadoopConfiguration(configuration); | |||
|
|||
if (System.getenv().get("IN_TESTS") != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aim of this change is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Integration test setup, the Yarn containers created by YarnMiniCluster does not have the Yarn site XML and KRB5 configuration files. We are adding these files as container local resources for the container applications (JM/TMs) to have proper secure cluster setup
+ ") WITH (\n" | ||
+ " 'connector' = 'blackhole'\n" | ||
+ ");\n" | ||
+ "INSERT INTO sink VALUES (1), (2), (3);"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test to cover the udf jar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because code freeze time is coming, I will add a test in another PR.
throw new SqlClientException( | ||
"Sql Client doesn't support to run init files when deploying script into cluster."); | ||
} | ||
boolean success = cli.executeInitialization(options.getInitFile()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confuse that what content are init file? is it sql query, sql ddl or config option? After see the line 147 and line 153 error message, I guess it is a sql query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can take a look at th doc.
Script file that used to init the session context. If ge error in execution, the sql client will exit. Notice it's not allowed to add query or insert into the init file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What is the purpose of the change
Support to deploy script via SQL Client.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation